<template>
  <div>
    <el-button type="warning" @click="del" :disabled="multipleSelection.length===0">批删</el-button>
  <el-table
      ref="filterTable"
      :data="tableData.list"
      border
      style="width: 100%"

      @selection-change="handleSelectionChange">
    <el-table-column
        type="selection"
        width="55">

    </el-table-column>
    <el-table-column
        prop="tid"
        label="教师编号"
        width="180">
    </el-table-column>
    <el-table-column
        prop="tname"
        label="姓名"
        width="180">
    </el-table-column>

    <el-table-column
        prop="roomVo.rname"
        label="班级"
        width="100"
        :filters="[{ text: '2306A', value: '2306A' }, { text: '2306B', value: '2306B' }, { text: '2307A', value: '2307A' }, { text: '2308A', value: '2308A' }]"
        :filter-method="filterTag"
        filter-placement="bottom-end">
      <template slot-scope="scope">
        <el-tag
            disable-transitions>{{scope.row.roomVo.rname}}</el-tag>
      </template>
    </el-table-column>


    <el-table-column
        prop="duties"
        label="职务"
        width="180">
    </el-table-column>
    <el-table-column
        prop="disctype"
        label="学科"
        width="180">
    </el-table-column>
  </el-table>
    <div class="block">
      <span class="demonstration">完整功能</span>
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[3,5,10]"
          :page-size="tableData.count"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {deleteRequest, getRequest} from "@/utils/api";
import axios from "axios";

export default {
  name: "Teachers",
  data(){
    return{
      tableData:[],
      multipleSelection:[],
      count:''
    }
  },
  methods:{
    handleSelectionChange(val) {
      this.multipleSelection=val
    },
    del(){
      var arr=''
      for(var i in this.multipleSelection){
        arr+=this.multipleSelection[i].tid+','
      }
      console.log(arr)
       deleteRequest("/student/delete?arr="+arr).then(xxx=>{
         if (xxx.data.flag){
           this.$message.success("删除成功")
            this.findtea();
         }
       })
    },
    findtea(){
      getRequest("/student/teachers?count="+this.count).then(resp =>{
        this.tableData=resp.data.data;
      })
    },
    filterTag(value, row) {
      return row.roomVo.rname == value;
    },
    handleSizeChange(val) {
      console.log(val+"条")
      this.count=val
      this.findtea()
    },
    handleCurrentChange(val) {
      console.log(val+"页")
      axios.get("student/teachers?offter="+val+"&count="+this.count).then(resp=>{
        this.tableData=resp.data.data
      })
    },
  },


  created() {
    this.findtea();
  }
}
</script>

<style scoped>
/*.el-table_*/
</style>